<?php
/**
 * Created by PhpStorm.
 * User: Jason
 * Date: 2017/9/21
 * Time: 15:53
 */

namespace Home\Service;


use Think\Model;

class ImageScoreService extends Model
{
    public function ScoreImg($scoreIds)
    {
        $map = array(
            'score_id'=>array('in',$scoreIds)
        );
        $res = M('ImageScore')->where($map)->select();
        $imageIds = array_column($res, 'image_id');
        $map = array(
            'id'=>array('in',$imageIds)
        );
        $images = M('Image')->where($map)->select();
        foreach ($images as $key => $image) {
            $imageMap[$image['id']] = $image;
        }
        foreach ($res as $key => $val) {
            $imgScoreMap[$val['score_id']] = $imageMap[$val['image_id']];
        }
        return $imgScoreMap;
    }
}